<script>
    $("#service").live('change', function() {        
        var selected_service = $("#service").val();
        if (selected_service == 'Insurance') {
            $(".row_non_insurance").hide("slow");
            $("#insurance").show("slow");
            $("#label_dynamic").text('Company name');
        }
        else {
            $(".row_non_insurance").show("slow");
            $("#insurance").hide("slow");
            $("#label_dynamic").text('Make');
        }
    });
</script>
<?php 
    echo form_open(base_url()."index.php/service/result"); 
?>
    <h1 class="blue">Service</h1>
    <table class="table_advance">
        <tbody>
            <tr>
                <td>Type of Service</td>
                <td>&nbsp;</td>                
                <td id="label_dynamic">Make</td>                
            </tr>
            <tr>
                <td>
                    <select name="service" id="service">
                        <option value="">Please select</option>
<?php 
                    foreach($service->result() as $row)
                    { 
?>
                        <option>
<?php 
                            echo $row->name;
?>
                        </option>
<?php
                    }
?>      
                    </select>                   
                </td>
                <td>&nbsp;</td>
                <td>
                    <input type="text" name="insurance" id="insurance" value="" class="hidden" />
                    <select name="make" class="row_non_insurance" id="make">
                        <option value="">Please select</option>
<?php 
                    foreach($make->result() as $row)
                    { 
?>
                        <option value="<?php echo $row->id; ?>">
<?php 
                            echo $row->name;
?>
                        </option>
<?php
                    }
?>                              
                    </select>                    
                </td>
            </tr>
            <tr>
                <td colspan="3">&nbsp;</td>
            </tr>
            <tr class="row_non_insurance">
                <td>Location</td>
                <td>&nbsp;</td>
                <td>Model</td>
            </tr>
            <tr class="row_non_insurance">
                <td>
                    <select name="location">
                        <option value="">Please select</option>
<?php 
                    foreach($location->result() as $row)
                    { 
?>
                        <option>
<?php 
                            echo $row->province;
?>
                        </option>
<?php
                    }
?>      
                    </select> 
                </td>
                <td>&nbsp;</td>
                <td>
                    <select name="model" id="model">
                        <option value="">Please select</option>
                    </select>                       
                </td>
            </tr>
            <tr>
                <td colspan="3">&nbsp;</td>
            </tr>
            <tr class="row_non_insurance">
                <td>Year</td>
                <td></td>
                <td></td>
            </tr>
            <tr class="row_non_insurance">
                <td>
                    <select name="year">
                        <option value="">Please select</option>
<?php
                    $current_year = date("Y");
                    for($counter = $current_year + 1; $counter >= 1950; $counter--)
                    {
?>
                        <option ><?php echo $counter; ?></option>
<?php                
                    }
?>                    
                    </select>
                </td>
                <td></td>
                <td>                   
                </td>
            </tr>
            <tr>
                <td colspan="3">&nbsp;</td>
            </tr>
            <tr>
                <td colspan="3">
                    <input type="submit" value="Search" name="submit" class="search" />
                </td>
            </tr>
        </tbody>
    </table>
<?php  
    echo form_close();
?>